package sign_in.loginsystem.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import sign_in.loginsystem.annotation.Permissions;
import sign_in.loginsystem.model.util.RBody;
import sign_in.loginsystem.model.util.Result;
import sign_in.loginsystem.service.port.RoleImp;
import sign_in.loginsystem.tool.Analyze;

@RestController
public class RoleController {

    @Autowired
    RoleImp roleService;

    @Autowired
    Analyze analyze;


    @PostMapping("/role")
    @Permissions(permission = "role:list")
    public Result allRole(@RequestBody RBody body){
        return Result.success(roleService.allRole(body));
    }

    @PostMapping("/createRole")
    @Permissions(permission =  "role:create")
    public Result createRole(@RequestBody RBody body){
        return Result.success(roleService.createRole(body));
    }

    @PostMapping("/editRole")
    @Permissions(permission = "role:edit")
    public Result editRole(@RequestBody RBody body){
        return Result.success(roleService.editRole(body));
    }

    @PostMapping("/delRole")
    @Permissions(permission = "role:delete")
    public Result delRole(@RequestBody RBody body){
        return Result.success(roleService.delRole(body));
    }

    @PostMapping("/allMenuRE")
    @Permissions(permission = "role:create")
    public Result allMenuRE(){
       return Result.success(roleService.allMenuRE());
    }
    @PostMapping("/roleRE")
    public Result roleRE(){
        return Result.success(roleService.roleRE());
    }
}
